﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Runtime.Remoting.Channels;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Login.Events;
using Microsoft.Practices.Prism.Mvvm;
using Microsoft.Practices.Prism.PubSubEvents;

namespace Login.ViewModels
{
    [Export]
   public class BottomPaneViewModel : BindableBase
    {

        private IEventAggregator _eventAggregator;
        private int _progressValue;
        public int ProgressValue
        {
            get { return _progressValue; }
            set { SetProperty(ref _progressValue, value); }
        }
        private int _allCount;
        public int AllCount
        {
            get { return _allCount; }
            set { SetProperty(ref _allCount, value); }
        }
        [ImportingConstructor]
        public BottomPaneViewModel(IEventAggregator eventAggregator)
        {
            _eventAggregator = eventAggregator;
            ProgressValue = 0;
            AllCount = 100;
            _eventAggregator.GetEvent<Process>().Subscribe(OnProcess);
        }
        private  void OnProcess(int process)
        {
            AllCount = process/1024;
            if (ProgressValue < AllCount)
            {
                ProgressValue++;
            }
        }
    }
}
